import { PrismaClient } from "@prisma/client";

const p = new PrismaClient()

const query = async (req, res) => {
    try {
        const members = await p.member.findMany({
            where: {
                AND: [
                    {
                        clubs: {
                            some: {
                                name: "Networking"
                            }
                        }
                    },
                    {
                        clubs: {
                            some: {
                                name: "Chemistry Industy"
                            }
                        }
                    }
                ]
            },
            select: {
                id: true,
                firstname: true,
                lastname: true,
                mobile: true,
                clubs: true
            }

        })
        res.json(members)
    }
    catch (e) {
        console.log(e);

        res.send(e)
    }

}

export default query

// gt: greater than 大于
// gte: greater than or equels 大于或等于
// lt: less than 小于
// lte: less than or equels 小于或等于